package dletc.Map;

import java.util.HashMap;
import java.util.Map;

public class Demo03 {

	public static void main(String[] args) {
		
		Map<String, Student> map = new HashMap<String, Student>();
		
		map.put("001", new Student("tom",23));
		map.put("002", new Student("gavin",24));
		map.put("003", new Student("jack",25));
		map.put("004", new Student("tom",23));
		
		System.out.println(map);
		
		System.out.println("--------------------------------------------");
		//自定义对象如果作为key值，一定要重写equals方法和hashCode方法
		Map<Student,String> map2 = new HashMap<Student,String>();
		map2.put(new Student("tom",23),"001");
		map2.put(new Student("gavin",24),"002");
		map2.put(new Student("jack",25),"003");
		map2.put(new Student("tom",23),"004");
		
		System.out.println(map2);
	}

}
